package com.xnyzc.lhy.mis.controller.cmsapi.citymanage;

import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.mis.entity.param.cms.city.CityParam;
import com.xnyzc.lhy.mis.entity.param.cms.dict.DictParam;
import com.xnyzc.lhy.mis.service.cms.citymanage.CityManageService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 城市管理Controller
 *
 * @author zhaolijie
 * @date 2019/08/29
 */
@RestController
@RequestMapping(value = "/cmsapi/citymanage")
public class CityManageController {

    @Autowired
    private CityManageService cityManageService;

    /**
     * 获取所有城市
     *
     * @return
     */
    @GetMapping(value = "/getAllCity")
    public Rv getAllCity() {
        return cityManageService.getAllCity();
    }
    /**
     * 获取所有上线城市
     *
     * @return
     */
    @GetMapping(value = "/getAllUsedCity")
    public Rv getAllUsedCity() {
        return cityManageService.getAllUsedCity();
    }
    /**
     * 查询开通城市
     *
     * @param current：当前页
     * @return
     */
    @GetMapping(value = "/getOpenAreaList")
    public Rv getOpenAreaList(Integer current) {
        return cityManageService.getOpenAreaList(current);
    }


    /**
     * 模糊查询开通城市
     *
     * @param current：查询页
     * @param areaId：区域表主键ID
     * @param isOpne：0-未开通。1-开通
     * @return
     */
    @GetMapping(value = "/getOpenAreaListLike")
    public Rv getOpenAreaListLike(Integer current, Long areaId, Integer isOpne) {
        return cityManageService.getOpenAreaListLike(current, areaId, isOpne);
    }

    @GetMapping(value = "/updateisOpne")
    public Rv updateisOpne(Long open_area_id, Integer isOpne) {
        return cityManageService.updateisOpne(open_area_id, isOpne);
    }

    @PostMapping(value = "/addCity")
    public Rv addCity(
            @ApiParam(name = "param", value = "接入传参") @RequestBody CityParam param
    ) {
        return cityManageService.addCity(param);
    }

    @ApiOperation(value = "开通城市关联详情", notes = "开通城市关联详情")
    @PostMapping(value = "/getCityDetails")
    public Rv getCityDetails(
            @ApiParam(name = "param", value = "接入传参") @RequestBody CityParam param
    ) {
        return Rv.wrap(cityManageService.getCityDetails(param));
    }

    @ApiOperation(value = "修改开通城市关联", notes = "修改开通城市关联")
    @PostMapping(value = "/getCityRelevance")
    public Rv getCityRelevance(
            @ApiParam(name = "param", value = "接入传参") @RequestBody CityParam param
    ) {
        return Rv.wrap(cityManageService.getCityRelevance(param));
    }

}
